package com.itheima.tlias84.mapper;

import com.itheima.tlias84.annotaion.ReportLog;
import com.itheima.tlias84.dto.SelectAllDeptDTO;
import com.itheima.tlias84.entity.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {


    @Select("select id, name,update_time from dept order by update_time desc ")
    List<SelectAllDeptDTO> selectAll();
    @ReportLog
    @Insert("insert into  dept (name ,update_time,crete_time) values (#{d.name},#{d.updateTime},#{d.creteTime})")
    int insertDept(@Param("d") Dept dept);
    @ReportLog
    @Delete("delete from dept where id = #{id}")
    int deleteById(@Param("id") Integer id);

    @Select("select id, name,update_time from dept where id = #{id}")
    SelectAllDeptDTO selectById(@Param("id")Integer id);
    @ReportLog
    @Update("update dept set name = #{d.name},update_time = #{d.updateTime} where id = #{d.id}")
    int updateById(@Param("d")Dept dept);


    int batchDelete(@Param("ids") List<Integer> ids);
}
